using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using RMSM;

namespace AC.Report
{
	public partial class ChupHinh : DevExpress.XtraReports.UI.XtraReport
	{
		private LanChupHinhBOCollection lanChupHinhBOCollection = null;

		public ChupHinh(string title, int HopDongID, CTChupHinhBOCollection chiTietChupHinhBOCollection, LanChupHinhBOCollection lanChupHinhBOCollection)
		{
			InitializeComponent();

			if (title == null)
				this.ReportHeader.Visible = false;
			else
				this.lblTitle.Text = title;

			if (lanChupHinhBOCollection == null)
				this.lanChupHinhBOCollection = LanChupHinhBOCollection.GetLanChupHinhBOCollection("HOPDONGID=" + HopDongID, "LANCHUPHINHID");
			else
				this.lanChupHinhBOCollection = lanChupHinhBOCollection;

			this.lblGhiChu.SummaryGetResult += new SummaryGetResultHandler(lblGhiChu_SummaryGetResult);
			this.lblNgayChup.SummaryGetResult += new SummaryGetResultHandler(lblNgayChup_SummaryGetResult);
			this.lblNgayChon.SummaryGetResult += new SummaryGetResultHandler(lblNgayChon_SummaryGetResult);
			this.lblNgayGiao.SummaryGetResult += new SummaryGetResultHandler(lblNgayGiao_SummaryGetResult);

			this.bds.DataSource = chiTietChupHinhBOCollection;
		}

		private void lblGhiChu_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanChupHinhID = (int)GetCurrentColumnValue("LanChupHinhID");
			LanChupHinhBO lanChupHinhBO = this.lanChupHinhBOCollection.GetBO(LanChupHinhID);
			e.Result = (string.IsNullOrEmpty(lanChupHinhBO.GhiChu) ? "" : lanChupHinhBO.GhiChu);
			e.Handled = true;
		}

		private void lblNgayChup_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanChupHinhID = (int)GetCurrentColumnValue("LanChupHinhID");
			LanChupHinhBO lanChupHinhBO = this.lanChupHinhBOCollection.GetBO(LanChupHinhID);
			if (lanChupHinhBO.NgayChup == null)
				e.Result = "";
			else
				e.Result = lanChupHinhBO.NgayChup.Value.ToString("dd/MM/yyyy  HH:mm");
			e.Handled = true;
		}

		private void lblNgayChon_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanChupHinhID = (int)GetCurrentColumnValue("LanChupHinhID");
			LanChupHinhBO lanChupHinhBO = this.lanChupHinhBOCollection.GetBO(LanChupHinhID);
			if (lanChupHinhBO.NgayChon == null)
				e.Result = "";
			else
				e.Result = lanChupHinhBO.NgayChon.Value.ToString("dd/MM/yyyy  HH:mm");
			e.Handled = true;
		}

		private void lblNgayGiao_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanChupHinhID = (int)GetCurrentColumnValue("LanChupHinhID");
			LanChupHinhBO lanChupHinhBO = this.lanChupHinhBOCollection.GetBO(LanChupHinhID);
			if (lanChupHinhBO.NgayGiao == null)
				e.Result = "";
			else
				e.Result = lanChupHinhBO.NgayGiao.Value.ToString("dd/MM/yyyy  HH:mm");
			e.Handled = true;
		}
	}
}
